﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using Caliburn.Core.InversionOfControl;
using Caliburn.PresentationFramework;
using Caliburn.PresentationFramework.Behaviors;
using MTGenome.MTG;

namespace MTGenome.ViewModels
{
    [Validate, PerRequest(typeof(QuickCardViewModel)), PartCreationPolicy(CreationPolicy.NonShared)]
    public class QuickCardViewModel : PropertyChangedBase
    {
        private readonly CardDetailViewModel _cardDetail = null;
        private bool _isSelected = false;

        public QuickCardViewModel(CardDetailViewModel cardDetail)
        {
            _cardDetail = cardDetail;
        }

        public ICard Card
        {
            get;
            set;
        }

        public virtual string Text
        {
            get { return Card == null ? string.Empty : Card.Name + " (" + Card.Expansion + ")"; }
        }

        public bool IsSelected
        {
            get { return _isSelected; }
            set
            {
                if (_isSelected != value)
                {
                    _isSelected = value;
                    _cardDetail.Card = Card;
                    NotifyOfPropertyChange(() => IsSelected);
                }
            }
        }
    }
}
